package com.lix.pojo.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Set;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * 用户信息表
 * @TableName t_user
 */
@Data
@TableName(value ="t_user")
@ApiModel("用户表")
public class User implements Serializable, UserDetails {

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @TableId(value = "user_id", type = IdType.ASSIGN_ID)
    private String userId;

    @ApiModelProperty("用户名")
    private String username;

    @ApiModelProperty("密码")
    private String password;

    @ApiModelProperty("头像地址")
    private String avatar;

    @ApiModelProperty("昵称")
    private String nickName;

    @ApiModelProperty("手机号")
    private String phone;

    @ApiModelProperty("邮箱地址")
    private String email;

    @ApiModelProperty("用户注册时间")
    private LocalDateTime createTime;

    @ApiModelProperty("用户修改时间")
    private LocalDateTime updateTime;

    @ApiModelProperty("用户签名")
    private String autograph;

    @ApiModelProperty("用户状态,1、正常 2、锁定")
    private Integer userStatus;

    @ApiModelProperty("积分")
    private Integer point;

    @ApiModelProperty("性别 1、男 2、女")
    private Integer sex;

    @ApiModelProperty("用户类型 1、新用户 2、老用户")
    private Integer userType;

    @TableField(exist = false) // 不是表中字段
    @ApiModelProperty("封装用户权限")
    private Set<GrantedAuthority> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

}